<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>查看珍品信息</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
    <style type="text/css">
        div{
            text-align: center;
        }
        th{
            text-align: center;
        }
        .fanye{
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="ibox-title">
        <h5>查看珍品信息</h5>
    </div>
    <form class="form-horizontal m-t" id="signupForm" action="{:url('getChoose')}" method="post" enctype="multipart/form-data">
        <div class="form-group">
            <label class="col-sm-1 control-label">茶类</label>
            <div class="col-sm-2">
                <select class="form-control m-b" name="teacase" style="font-size: 12px;">
                    <option value="{$current['id']}">{$current['teaname']}</option>
                    {foreach $teacase as $case}
                    <option value="{$case['id']}">{$case['teaname']}</option>
                    {/foreach}
                </select>
            </div>

            <label class="col-sm-1 control-label">产区</label>
            <div class="col-sm-2">
                <select class="form-control m-b" name="teaarea" style="font-size: 12px;">
                    <option value="{$currentArea['id']}">{$currentArea['area']}</option>
                    {foreach $teaarea as $area}
                    <option value="{$area['id']}">{$area['area']}</option>
                    {/foreach}
                </select>
            </div>
            <div class="col-sm-2">
                <button class="btn btn-primary" type="submit">提交</button>
            </div>
        </div>
    </form>

    <div class="form-group">

    </div>

    <div class="form-horizontal m-t">
        <div class="form-group">
            <label class="col-sm-1 control-label">显示</label>
            <div class="col-sm-5">
                <label class="checkbox-inline">
                    <input type="checkbox" class="" id="inlineCheckbox6" >茶类</label>
                <label class="checkbox-inline">
                    <input type="checkbox" class="" id="inlineCheckbox7" >产地</label>
                <label class="checkbox-inline">
                    <input type="checkbox" class="" id="inlineCheckbox8" checked>出品人</label>
                <label class="checkbox-inline">
                    <input type="checkbox" class="" id="inlineCheckbox9">荣誉</label>
                <label class="checkbox-inline">
                    <input type="checkbox" class="" id="inlineCheckbox11" checked>零售价格</label>
                <label class="checkbox-inline">
                    <input type="checkbox" class="" id="inlineCheckbox3">微信</label>
                <label class="checkbox-inline">
                    <input type="checkbox" class="" id="inlineCheckbox4">详细介绍</label>
            </div>
        </div>
    </div>

    <div class="ibox-content">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th class='case'></th>
                    <th class='area'></th>
                    <th >珍品名称</th>
                    <th >分数（60~100的数字）</th>
                    <th>评价</th>
                    <th class='producer'>出品人</th>
                    <th class="price">零售价/500g</th>
                    <th class="zs"></th>
                    <th class="gs"></th>
                    <th class="ct"></th>
                    <th class="ds"></th>
                    <th class="other"></th>
                    <th >联系人</th>
                    <th >电话</th>
                    <th class="wechat"></th>
                    <th class="detailintro"></th>
                    <th >修改</th>
                    <th >删除</th>
                </tr>
            </thead>
            <tbody>
                {foreach $data as $onedata}
                <tr index = "{$onedata['id']}">
                    <!-- 茶类 -->
                    <td >
                        <select class="form-control m-b" name="chooseteacase" style="font-size: 12px;width: 90px;display: none;">
                            <option value="{$current['id']}">{$current['teaname']}</option>
                            {foreach $teacase as $case}
                            <option value="{$case['id']}">{$case['teaname']}</option>
                            {/foreach}
                        </select>
                    </td >
                    <!-- 产区 -->
                    <td >
                        <select class="form-control m-b" name="chooseteaarea" style="font-size: 12px;display: none;">
                            <option value="{$currentArea['id']}">{$currentArea['area']}</option>
                            {foreach $teaarea as $area}
                            <option value="{$area['id']}">{$area['area']}</option>
                            {/foreach}
                        </select>
                    </td >

                    <!-- 名称 -->
                    <td>
                        <input index="" type="text" name="name" value="{$onedata['name']}" style="width: 80px;text-align: center;border: none;">
                    </td>
                    <!-- 评分 -->
                    <td>
                        <input type="text" name="score" value="{$onedata['score']}" style="width: 60px;border: none;text-align: center;">
                    </td>
                    <td>A++</td>
                    <!-- 出品人 -->
                    <td>
                        <input type="text" name="producer" value="{$onedata['producer']}" style="width: 150px;text-align: center;border: none;">
                    </td>
                    <!-- 零售价 -->
                    <td>
                        <input type="text" name="price" value="{$onedata['price']}" style="width: 60px;border: none;text-align: center;">
                    </td>
                    <!-- 荣誉 -->
                    <td>
                        {switch name ='$onedata.zs'}
                        {case value = "√"}
                        <input type="checkbox" name="zs" id="honor" value="√" style="display: none;"checked>
                        {/case}
                        {case value = "×"}
                        <input type="checkbox" name="zs" id="honor" value="×" style="display: none;">
                        {/case}
                        {/switch}
                    </td>
                    <td>
                        {switch name = '$onedata.gs'}
                        {case value = "√"}
                        <input type="checkbox" name="gs" id="honor" value='√' style="display: none;" checked>
                        {/case}
                        {case value = "×"}
                        <input type="checkbox" name="gs" id="honor" value="×" style="display: none;">
                        {/case}
                        {/switch}
                    </td>
                    <td>
                        {switch name = '$onedata.ct'}
                        {case value = "√"}
                        <input type="checkbox" name="ct" id="honor" value='√' style="display: none;" checked>
                        {/case}
                        {case value = "×"}
                        <input type="checkbox" name="ct" id="honor" value='×' style="display: none;">
                        {/case}
                        {/switch}

                    </td>
                    <td>
                        {switch name = '$onedata.ds'}
                        {case value = "√"}
                        <input type="checkbox" name="ds" id="honor" value='√' style="display: none;" checked>
                        {/case}
                        {case value = "×"}
                        <input type="checkbox" name="ds" id="honor" value='×' style="display: none;">
                        {/case}
                        {/switch}

                    </td>
                    <td>
                        <input type="text" name="other" id="honor" value="{$onedata['other']}" style="width: 60px;border: none;text-align: center;display: none;">
                    </td>
                    <!-- 联系人 -->
                    <td>
                        <input type="text" name="contact" value="{$onedata['contact']}" style="width: 60px;border: none;text-align: center;">
                    </td>
                    <!-- 手机 -->
                    <td>
                        <input type="text" name="phone" value="{$onedata['phone']}" style="width: 100px;border: none;text-align: center;">
                    </td>
                    <!-- 微信 -->
                    <td>
                        <input type="text" name="wechat" value="{$onedata['wechat']}" style="width: 100px;border: none;text-align: center;display: none;">
                    </td>


                    <!-- 详细介绍 -->
                    <td >
                        <textarea cols="50" rows="6" name="detailintro" style="border: none;display: none;">{$onedata['detailintro']}"
                        </textarea>
                    </td>
                    <td>
                        <button class="modify" index="{$onedata['id']}">修改</button>
                    </td>
                    <td>
                        <button class="del" del="{$onedata['id']}" data-toggle="modal"  data-target="#delmod">删除</button>
                    </td>
                </tr>
                {/foreach}
                <!-- <tr>
                    <td>乌龙茶</td>
                    <td>武夷岩茶</td>
                    <td><span>唐僧肉</span></td>
                    <td>张三/XX公司</td>
                    <td><input type="checkbox" name="zs" id="inlineCheckbox1" value='√'></td>
                    <td><input type="checkbox" name="gs" id="inlineCheckbox1" value='√'></td>
                    <td><input type="checkbox" name="ct" id="inlineCheckbox1" value='√'></td>
                    <td><input type="checkbox" name="ds" id="inlineCheckbox1" value='√'></td>
                    <td>三坑两润</td>
                    <td>92000</td>
                    <td>李四</td>
                    <td>13612345678</td>
                    <td>13612345678</td>
                    <td >
                        <button type="button"  data-toggle="modal" data-target="#myModal">
                          查看
                        </button>
                    </td>
                    <td><button>修改</button></td>
                    <td><button>删除</button></td>
                </tr> -->
            </tbody>
        </table>
    </div>



    <!-- 删除提示Modal -->
    <div class="modal fade" id="delmod" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">确定要删除吗？</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="id" class="delID">
                    <p>删除后将不可恢复！！！</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-default confirmDel" data-dismiss="modal" >删除</button>
                </div>
            </div>
        </div>
    </div>



<!-- 全局js -->
<script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__STATIC__/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__STATIC__/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="__STATIC__/js/hAdmin.js?v=4.1.0"></script>
<script type="text/javascript" src="__STATIC__/js/index.js"></script>
<script type="text/javascript">

    //删除
    $(".del").click(function(){
        var id = $(this).attr("del");
        $("input.delID").val(id);
    })

    //确认删除
    $("button.confirmDel").click(function(){
        var delID = $("input.delID").val();
        var url = "{:url('delZp')}";
        var data = {id:delID};
        $.post(url, data, function(data){
            if(data==1){
                $("tr[index="+delID+"]").remove();
                alert("删除成功");
            }
        });

    })

    $("input[type=checkbox]").click(function(){
        var value = $(this).attr("value");
        if(value=="√"){
            $(this).attr("value","×");
        }else{
            $(this).attr("value","√");
        }
    })

    //修改
    $(".modify").click(function(){
        var url = "{:url('modifyZpin')}";
        var id = $(this).attr("index");
        var teacase = $(this).parents('tr').find("select[name=chooseteacase]").val();
        var teaarea = $(this).parents('tr').find("select[name=chooseteaarea]").val();
        var name= $(this).parents('tr').find("input[name=name]").val();
        var producer =$(this).parents('tr').find("input[name=producer]").val();
        var zs =$(this).parents('tr').find("input[name=zs]").val();
        var gs =$(this).parents('tr').find("input[name=gs]").val();
        var ct =$(this).parents('tr').find("input[name=ct]").val();
        var ds =$(this).parents('tr').find("input[name=ds]").val();
        var other =$(this).parents('tr').find("input[name=other]").val();
        var price =$(this).parents('tr').find("input[name=price]").val();
        var contact =$(this).parents('tr').find("input[name=contact]").val();
        var phone =$(this).parents('tr').find("input[name=phone]").val();
        var wechat =$(this).parents('tr').find("input[name=wechat]").val();
        var score =$(this).parents('tr').find("input[name=score]").val();
        var detailintro =$(this).parents('tr').find("textarea[name=detailintro]").val();

        var data = {
            id:id,
            teacase:teacase,
            teaarea:teaarea,
            name:name,
            producer:producer,
            zs:zs,
            gs:gs,
            ct:ct,
            ds:ds,
            other:other,
            price:price,
            contact:contact,
            phone:phone,
            wechat:wechat,
            score:score,
            detailintro:detailintro
        };

        $.post(url,data,function(data){
            if(data == 1){
                alert('修改成功');
            }else{
                alert('修改失败');
            }
        })
    })

    //隐藏
    $("#inlineCheckbox1").click(function(){
        var a = $("th[class=contact]").html();
        if(a == '联系人'){
            $("th[class=contact]").html('')
        }else{
            $("th[class=contact]").html('联系人')
        }
        $("input[name=contact]").toggle();

    })


    $("#inlineCheckbox2").click(function(){
        var a = $("th[class=phone]").html();
        if(a == '电话'){
            $("th[class=phone]").html('')
        }else{
            $("th[class=phone]").html('电话')
        }
        $("input[name=phone]").toggle();

    })

    //微信
    $("#inlineCheckbox3").click(function(){
        var a = $("th[class=wechat]").html();
        if(a == ''){
            $("th[class=wechat]").html('微信')
        }else{
            $("th[class=wechat]").html('')
        }
        $("input[name=wechat]").toggle();

    })

    // 详细介绍
    $("#inlineCheckbox4").click(function(){
        var a = $("th[class=detailintro]").html();
        if(a == ''){
            $("th[class=detailintro]").html('详细')
        }else{
            $("th[class=detailintro]").html('')
        }
        $("textarea[name=detailintro]").toggle();

    })

    $("#inlineCheckbox5").click(function(){
        var a = $("th[class=detailintro]").html();
        if(a == '详情'){
            $("th[class=detailintro]").html('')
        }else{
            $("th[class=detailintro]").html('详情')
        }
        $("textarea[name=detailintro]").toggle();

    })

    $("#inlineCheckbox6").click(function(){
        var a = $("th[class=case]").html();
        if(a == ''){
            $("th[class=case]").html('茶类')
        }else{
            $("th[class=case]").html('')
        }
        $("select[name=chooseteacase]").toggle();

    })

    $("#inlineCheckbox7").click(function(){
        var a = $("th[class=area]").html();
        if(a == ''){
            $("th[class=area]").html('产地')
        }else{
            $("th[class=area]").html('')
        }
        $("select[name=chooseteaarea]").toggle();

    })

    $("#inlineCheckbox8").click(function(){
        var a = $("th[class=producer]").html();
        if(a == ''){
            $("th[class=producer]").html('出品人');
        }else{
            $("th[class=producer]").html('');
        }

        $("input[name=producer]").toggle();

    })

    $("#inlineCheckbox9").click(function(){
        var a = $("th[class=zs]").html();
        if(a == ''){
            $("th[class=zs]").html('正山出品')
        }else{
            $("th[class=zs]").html('')
        }

        a = $("th[class=gs]").html();
        if(a == ''){
            $("th[class=gs]").html('古树老丛')
        }else{
            $("th[class=gs]").html('')
        }

        a = $("th[class=ct]").html();
        if(a == ''){
            $("th[class=ct]").html('传统工艺')
        }else{
            $("th[class=ct]").html('')
        }

        a = $("th[class=ds]").html();
        if(a == ''){
            $("th[class=ds]").html('大师手制')
        }else{
            $("th[class=ds]").html('')
        }

        a = $("th[class=other]").html();
        if(a == ''){
            $("th[class=other]").html('其他')
        }else{
            $("th[class=other]").html('')
        }

        $("input[id=honor]").toggle();

    })

    //零售价格
    $("#inlineCheckbox11").click(function(){
        var a = $("th[class=price]").html();
        if(a == ''){
            $("th[class=price]").html('零售价格')
        }else{
            $("th[class=price]").html('')
        }
        $("input[name=price]").toggle();

    })


    $("select[name=teacase] ").change(function(){
        var val = $(this).find("option:selected").attr("value");
        var url="{:url('reTeaAreaJson')}";
        $.post(url, {teacase_id:val},function(data){
            var areas = JSON.parse(data);
            var option="";
            for(index in areas){
                // console.log(areas[index]["area"])
                var a = "<option value="+areas[index]['id']+">"+areas[index]['area']+"</option>"
                option +=a

            }
            // console.log(option);

            $("select[name=teaarea]").html(option)
        })
    })


</script>

</body>
</html>